<?php
namespace iot\controllers;


use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;


include_once '../../lib/aliyun-php-sdk-core/Config.php';
use \Iot\Request\V20170420\RegistDeviceRequest;
use yii\web\Response;

/**
 * Site controller
 */
class InitController extends Controller
{

    /**
     * Displays homepage.
     *
     * @return string
     */
    public function actionIndex()
    {
        $accessKeyId = "LTAIy8dX7j1omWO1";
        $accessSecret = "E5LyOmoFLI9iTv6t3KwJgFDQyrlxAQ";
        $iClientProfile = \DefaultProfile::getProfile("cn-shanghai", $accessKeyId, $accessSecret);
        $client = new \DefaultAcsClient($iClientProfile);
        $request = new RegistDeviceRequest();
        $request->setDeviceName("leotest2222");
        $request->setProductKey("jmibOFirUOO");
        $response = $client->getAcsResponse($request);
        Yii::$app->response->format = Response::FORMAT_JSON;
        return $response;
    }

}
